# -*- coding: utf-8 -*-
# -----------------------------------------
# @Time       : 2020/2/11 19:13
# @Author     : dqz 
# @Email      : 1406990390@qq.com
# @File       : dir_files.py
# @Software   : PyCharm
# -----------------------------------------

import os
from config.settings import BASE_DIR

class DirFile:
    def __init__(self,dir=os.path.join(BASE_DIR,'conf')):
        self.dir=dir

    def get_dir(self):
        return self.dir

    def get(self,reg=None):
        files = []
        if not os.path.isdir(self.dir):
            return files
        if not reg:
            return os.listdir(self.dir)

        for file in os.listdir(self.dir):
            if file.startswith(reg) and os.path.isfile(os.path.join(self.dir,file)):
                files.append(file)
        return files


